package com.sk.bilibili.view.fragment.main.home.home;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.sk.bilibili.adapter.vlayout.VideoSetAdapter;
import com.sk.bilibili.bean.VideoSet;
import com.sk.bilibili.callBack.FullVideoSetCallBack;
import com.sk.bilibili.model.fragment.main.home.home.RecommendModel;
import com.sk.bilibili.view.activity.MemberActivity;
import com.sk.bilibili.view.activity.VideoSetActivity;
import com.sk.bilibili.view.diy.bottomDialog.LaterBottomDialog;
import com.sk.bilibili.view.fragment.BaseRefreshFragment;

import java.util.List;

public class RecommendFragment extends BaseRefreshFragment<RecommendModel> implements FullVideoSetCallBack {

    private VideoSetAdapter videoSetAdapter;
    private LaterBottomDialog laterBottomDialog;

    public RecommendFragment() {
        laterBottomDialog=new LaterBottomDialog();
    }

    @Override
    protected void initAdapter(DelegateAdapter adapter) {
        videoSetAdapter = new VideoSetAdapter(getContext(),this);
        adapter.addAdapter(videoSetAdapter);
    }

    public void loadSuccess(List<VideoSet> videoSets) {
        videoSetAdapter.addData(videoSets);
    }

    public void refreshSuccess(List<VideoSet> videoSets) {
        videoSetAdapter.setData(videoSets);
        cancelRefresh();
    }

    @Override
    public void onClickVideoSet(Integer id) {
        VideoSetActivity.start(getContext(),id);
    }

    @Override
    public void onClickMember(Integer id) {
        MemberActivity.start(getContext(),id);
    }

    @Override
    public void onClickMore(Integer id) {
        laterBottomDialog.show(getChildFragmentManager(),id);
    }

}